package com.jboost.modules.app.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Maps;
import com.jboost.modules.app.dto.BomItem;
import com.jboost.modules.app.util.StrategyFactory;
import com.jboost.modules.system.entity.FhdBom;
import com.jboost.modules.system.entity.FhdProductDz;
import com.jboost.modules.system.mapper.FhdBomMapper;
import com.jboost.modules.system.mapper.FhdProductMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

@Api(tags = "客户管理")
@RestController
@RequestMapping("/moodytiger")
@Slf4j
@AllArgsConstructor
public class MoodytigerController {

    @GetMapping(value = "/bom-copy")
    @ApiOperation(value = "cj5", notes = "cj5")
    public List<Map> cj5(String v) throws Exception {
        String[] s = v.split("-");
        List<Map> list = Lists.newArrayList();
        String[] split = s[0].split(",");
        for (int i = 0; i < split.length; i++) {
            Map map = new HashMap();
            for (int j = 0; j < s.length; j++) {
                try {
                    map.put(j + "", s[j].split(",")[i]);

                }catch (Exception exception){
                }

            }
            list.add(map);
        }
        return list;
    }


    @GetMapping(value = "/qhsp")
    @ApiOperation(value = "cj11", notes = "cj5")
    public List<Map> cj11(String cmmx,String yszw) throws Exception {
        String[] cmmxs = cmmx.split(",");
        String[] yszws = yszw.split(",");
        AtomicInteger i = new AtomicInteger(0);
        List<String> collect = Arrays.stream(cmmxs).map(e -> {
            ArrayList<String> objects = Lists.newArrayList();
            for (String s : yszws) {
                objects.add(e + "*" + s);
            }
            return objects;
        }).collect(Collectors.toList()).stream().flatMap(Collection::stream).collect(Collectors.toList());
   return collect.stream().map(e->{
        HashMap<String, String> va = Maps.newHashMap();
        va.put("value",e);
        va.put("no",i.incrementAndGet()+"");
        return va;
    }).collect(Collectors.toList());
    }


}
